<?php

class Dmd_Resource_Transport extends  Zend_Application_Resource_ResourceAbstract
{
    private $config;
    private $host = '';
    
    public function init() {
        $config_ini = new Zend_Config_Ini(APPLICATION_PATH . '/configs/mail.ini', 'production');

        $this->config = array(
            'auth' => $config_ini->mailer->smtp->auth,
            'username' => $config_ini->mailer->smtp->username,
            'password' => $config_ini->mailer->smtp->password,
            'ssl' => $config_ini->mailer->smtp->ssl,
            'port' => (int)$config_ini->mailer->smtp->port,
        );

        $this->host = ($config_ini->mailer->smtp->host == '') ? '127.0.0.1' : $config_ini->mailer->smtp->host;

        try {
            $mailTransport = new Zend_Mail_Transport_Smtp($this->host, $this->config);
            return $mailTransport;
        } catch (Zend_Exception $e){
            //Do something with exception
        }
    }
    
}